package com.cddx.logistics.controller;

import com.cddx.logistics.domain.dto.TransferPageDTO;
import com.cddx.logistics.domain.pojo.TransferRecord;
import com.cddx.logistics.service.TransferService;
import com.cddx.logistics.util.model.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/transfer")
@Api(tags = "物料转移记录模块")
public class TransferController {
    @Autowired
    private TransferService transferService;
    @PostMapping("/list")
    @ApiOperation("物料转移记录列表分页查询")
    public  R  transferList(TransferPageDTO transferPageDTO){
        return transferService.transferList(transferPageDTO);
    }
    @DeleteMapping("/delete")
    @ApiOperation("批量删除物料转移记录")
    public R deleteTransfer(@RequestBody List<Integer> ids){
        return transferService.deleteTransfer(ids);
    }
    @DeleteMapping("/delete/{id}")
    @ApiOperation("单条删除物料转移记录")
    public R deleteTransferById(@PathVariable Integer id){
        return transferService.deleteTransfer(id);
    }

    @PostMapping("/add")
    @ApiOperation("添加物料转移记录")
    public R addTransfer(@RequestBody TransferRecord transferRecord){
        return transferService.addTransfer(transferRecord);
    }
    @PostMapping("/update")
    @ApiOperation("修改物料转移记录")
    public R updateTransfer(@RequestBody TransferRecord transferRecord){
        return transferService.update(transferRecord);
    }
    @GetMapping("/getTransferWarehouses")
    @ApiOperation("获取物料转移记录的仓库")
    public R getTransferWarehouse(){
        return transferService.getTransferWarehouses();
    }
    @GetMapping("/getTransferLocation")
    @ApiOperation("获取物料转移记录搜索框的库位（根据仓库id）")

    public R getTransferLocation(Long warehouseId){
        return transferService.getTransferLocation(warehouseId);
    }
    @GetMapping("/getTransferAddLocation")
    @ApiOperation("获取物料转移记录的添加库位")
    //从库位表中查仓库
    public R getTransferAddWarehouse(){
        return transferService.getTransferAddLocation();
    }
}
